<?php


require_once( "PhpFaces/EL/EL.php" );
require_once( "PhpFaces/Application/NavigationHandler.php" );
require_once( "PhpFaces/Application/ViewHandler.php" );


class PhpFaces_Application_Application {

	private $config;
	private $viewHandler;
	private $navigationHandler;
	
	private $logger;
	
	public function __construct() {
		$this->logger = LoggerManager::GetLogger( "PhpFaces.Application" );
		$this->variableResolver = new PhpFaces_EL_VariableResolver();
		$this->propertyResolver = new PhpFaces_EL_PropertyResolver();
	}
	
	public function getViewHandler() {
		return $this->viewHandler;	
	}
	public function setViewHandler( PhpFaces_Application_ViewHandler $viewHandler ) {
		$this->viewHandler = $viewHandler;
		$this->logger->debug( "setViewHandler: $viewHandler" );
	}
	
	public function getNavigationHandler() {
		return $this->navigationHandler;
	}
	public function setNavigationHandler( PhpFaces_Application_NavigationHandler $navigationHandler ) {
		$this->navigationHandler = $navigationHandler;
		$this->logger->debug( "setNavigationHandler: $navigationHandler" );
	}
	
	private $componentMap = array();
	public function addComponent( $componentType, $className ) {
		$this->componentMap[ $componentType ] = $className;
	}
	
	public function createComponent( $componentType ) {
		$className = $this->componentMap[ $componentType ];
		if( $className == null ) {
			throw new Exception( "Could not instantiate component componentType = $componentType" );
		}
		
		$instance = new $className;
		
		return $instance;
	}
	
	private $variableResolver;
	private $propertyResolver;
	
	public function getVariableResolver() {
		return $this->variableResolver;
	}
	
	public function getPropertyResolver() {
		return $this->propertyResolver;
	}
}


?>